//
//  ConEditCardViewController.m
//  Shengzhuli
//
//  Created by FXGuo on 17/3/21.
//  Copyright © 2017年 kamangkeji. All rights reserved.
//

#import "ConEditCardViewController.h"
#import "EditCardCell.h"
#import "QRCodeCell.h"
#import "SZLAccountHelper.h"
#import "QRCodeCreateTool.h"
#import "ConProvincesModel.h"
#import "ProvincesPicker.h"
#import "PersonNetWork.h"
#import "MBProgressHUD+MJ.h"
#import "VefityTool.h"
#import "ChatViewController.h"
#import "SZLTabBarViewController.h"
#import "ShowShareView.h"
#import "WaterRippleWait.h"
#import "ShareTool.h"
#import "ShareContentModel.h"

@interface ConEditCardViewController ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate> {
    
    UIView *shareView;
    UIButton *shareButton;
    UIScrollView *cardView;
    UIButton *cardBottomBtn;
    UILabel *nameLabel;
    UILabel *phoneLabel;
    UILabel *emailLbael;
    UILabel *addressLabel;
    UIImageView *erweimaView;
    UILabel *leftLabel;
    UILabel *rightLabel;
}

@property (nonatomic,strong) NSArray *titles;
@property (nonatomic,strong) NSArray *placeHolders;
@property (nonatomic,strong) NSArray *tips;
@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,assign) BOOL isClickEdit;//显示个人的编辑/生成
@property (nonatomic,strong) UIButton *footBtn;
@property (nonatomic,strong) QRCodeCell *headView;
@property (nonatomic,strong) ProvincesPicker *cityPicker;
@property (nonatomic,strong) PersonInfo *personInfo;//个人信息

@end

@implementation ConEditCardViewController

- (void)textFieldDidEndEditing:(UITextField *)textField {
    NSLog(@"🌹==%ld",textField.tag);
    
    switch (textField.tag) {
        case 0:
            self.info.name = textField.text;//姓名
            break;
        case 1:
            self.info.cardPhone = textField.text;//手机号
            break;
        case 2:
            self.info.position = textField.text;//身份
            break;
        case 10:
            self.info.proIdNames = textField.text;//提供资源
            break;
        case 11:
            self.info.demIdNames = textField.text;//需求资源
            break;
        case 20:
            self.info.detailedAddress = textField.text;//地址
            break;
        case 21:
            self.info.emailAddress = textField.text;//邮箱
            break;
            
        default:
            break;
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"编辑名片";
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    shareButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    shareButton.frame = CGRectMake(0, 0, 60, 60);
    shareButton.titleLabel.font = [UIFont systemFontOfSize:17];
    [shareButton setTitle:@"分享" forState:(UIControlStateNormal)];
    [shareButton addTarget:self action:@selector(shareMyCard) forControlEvents:(UIControlEventTouchUpInside)];
    shareButton.hidden = YES;
    UIBarButtonItem *shareItem = [[UIBarButtonItem alloc] initWithCustomView:shareButton];
    self.navigationItem.rightBarButtonItem = shareItem;
    
    cardView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, -64, ScreenW,ScreenH)];
    cardView.backgroundColor = [UIColor whiteColor];
    cardView.hidden = YES;
    
    UIImage *img1 = [UIImage imageNamed:@"正面1"];
    UIImageView *imgV1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 80, ScreenW,img1.size.height * ScreenW/img1.size.width)];//h/img1.size.height = ScreenW/img1.size.width
    imgV1.image = img1;
    [cardView addSubview:imgV1];
    
    UIImage *img2 = [UIImage imageNamed:@"背面"];
    UIImageView *imgV2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 80+imgV1.size.height+20, ScreenW,img2.size.height * ScreenW/img2.size.width)];
    imgV2.image = img2;
    [cardView addSubview:imgV2];
    
    cardBottomBtn = [[UIButton alloc]initWithFrame:CGRectMake(80, 80+imgV1.size.height+20+imgV2.size.height+20, ScreenW-160, 40)];
    cardBottomBtn.backgroundColor = RGBColorA(50, 134, 189, 1);
    [cardBottomBtn setTitle:@"重新编辑" forState:(UIControlStateNormal)];
    cardBottomBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [cardBottomBtn addTarget:self action:@selector(cardBottomBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [cardView addSubview:cardBottomBtn];
    
    [cardView setContentSize:CGSizeMake(0, cardBottomBtn.origin.y + cardBottomBtn.size.height +100)];
    
    nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenW/2, imgV1.size.height/3, ScreenW/2,imgV1.size.height/3)];
    nameLabel.textAlignment = NSTextAlignmentCenter;
    nameLabel.textColor = [UIColor whiteColor];
    nameLabel.numberOfLines = 0;
    nameLabel.font = [UIFont boldSystemFontOfSize:15];
    [imgV1 addSubview:nameLabel];
    
    phoneLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenW/2-50, imgV1.size.height*2/3, ScreenW/2+50,imgV1.size.height/9)];
    phoneLabel.numberOfLines = 1;
    phoneLabel.textAlignment = NSTextAlignmentLeft;
    phoneLabel.textColor = [UIColor whiteColor];
    phoneLabel.font = [UIFont systemFontOfSize:15];
    [imgV1 addSubview:phoneLabel];
    
    emailLbael = [[UILabel alloc] initWithFrame:CGRectMake(ScreenW/2-50, imgV1.size.height*7/9, ScreenW/2+50,imgV1.size.height/9)];
    emailLbael.numberOfLines = 1;
    emailLbael.textAlignment = NSTextAlignmentLeft;
    emailLbael.textColor = [UIColor whiteColor];
    emailLbael.font = [UIFont systemFontOfSize:15];
    [imgV1 addSubview:emailLbael];
    
    addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenW/2-50, imgV1.size.height*8/9, ScreenW/2+50,imgV1.size.height/9)];
    addressLabel.numberOfLines = 1;
    addressLabel.textAlignment = NSTextAlignmentLeft;
    addressLabel.textColor = [UIColor whiteColor];
    addressLabel.font = [UIFont systemFontOfSize:15];
    [imgV1 addSubview:addressLabel];
    
    erweimaView = [[UIImageView alloc] initWithFrame:CGRectMake(0-2, imgV2.size.height*152/594, ScreenW,imgV2.size.height*213/594)];
    erweimaView.contentMode = UIViewContentModeScaleAspectFit;
    if ([SZLAccountHelper isAlreadyLogin]) {
        erweimaView.image = [QRCodeCreateTool createQRCodeWithString:[NSString stringWithFormat:@"%@user/saoUserCard/info/send?mobilePhone=%@",PublicServer,[SZLAccountHelper shareInstance].mobilePhone]];
    }
    [imgV2 addSubview:erweimaView];
    
    leftLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, imgV2.size.width*0.2,imgV2.size.height-20)];
    leftLabel.textAlignment = NSTextAlignmentRight;
    leftLabel.textColor = [UIColor whiteColor];
    leftLabel.numberOfLines = 0;
    leftLabel.font = [UIFont boldSystemFontOfSize:17];
    [imgV2 addSubview:leftLabel];
    
    rightLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenW-10-imgV2.size.width*0.2, 10, imgV2.size.width*0.2,imgV2.size.height-20)];
    rightLabel.textAlignment = NSTextAlignmentLeft;
    rightLabel.textColor = [UIColor whiteColor];
    rightLabel.numberOfLines = 0;
    rightLabel.font = [UIFont boldSystemFontOfSize:17];
    [imgV2 addSubview:rightLabel];
    
    if (self.type == EditTypeShowSelf) {
        [self setTableViews];
        [self getCardInfo];
    }else if(self.type == EditTypeAddFriends) { //通过扫描进入名片
        self.title = @"个人名片";
        [self configHeadFooter];
        [self setTableViews];
    }else if(self.type == EditTypeShowOther) {
        self.title = @"个人名片";
        [self setTableViews];
        [self getOtherCardInfo];
    }else if(self.type == EditTypeChatWithSeller) {
        self.title = @"个人名片";
        [self setTableViews];
        [self getOtherCardInfo];
        [self getPersonInfo];
    }
    
    UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenW,85)];
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenW,8)];
    view.backgroundColor = RGBColorA(239, 239, 239, 1);
    [bottomView addSubview:view];
    [bottomView addSubview:self.footBtn];
    bottomView.backgroundColor = [UIColor whiteColor];
    self.tableView.tableFooterView = bottomView;
    
    [self.view addSubview:cardView];//cardView加在tableview的上方
    
}
- (void)shareMyCard {
    
    
    ShareContentModel  *model = [[ShareContentModel alloc] init];
    model.title = [self.info.name stringByAppendingString:@"-名片"];
    
    model.sharePicUrl = self.portraitUrl;
    //model.sharePicUrl = self.info.portraitUrl;
    model.content = [@"提供资源：" stringByAppendingString:self.info.proIdNames];
    model.pageUrl =self.info.shareUrl;
    NSLog(@"model.title = %@  model.sharePicUrl = %@model.content = %@ model.pageUrl = %@",model.title,model.sharePicUrl,model.content,model.pageUrl);
    [ShareTool share:model];
}
- (void)cardBottomBtnClick {
    if (self.type == EditTypeAddFriends) {
        [self addFriends];
        return;
    }
    if (self.type == EditTypeChatWithSeller) {
        ChatViewController *chatController = [[ChatViewController alloc]initWithConversationChatter:self.info.cardPhone conversationType:EMConversationTypeChat];
        chatController.title = self.info.name.length > 0 ? self.info.name : self.info.mobilePhone;
        chatController.info = self.personInfo;
        EaseUserModel *model = [[EaseUserModel alloc]initWithBuddy:self.info.mobilePhone];
        model.nickname = self.info.nickName;
        model.avatarURLPath = self.info.portraitUrl;
        model.ID = self.ID;
        chatController.model = model;
        [self.navigationController pushViewController:chatController animated:YES];
        return;
    }
    
    self.isClickEdit = YES;//还未生成名片，为编辑状态，显示输入框
    cardView.hidden = YES;
    shareButton.hidden = YES;
    self.title = @"编辑名片";
}

- (void)setTableViews
{
    self.titles = @[@[@"姓名",@"手机",@"身份"],@[@"提供资源",@"需求资源"],@[@"详细地址",@"邮箱地址"]];
    self.placeHolders = @[@[@"请输入您的真实姓名",@"请输入您的手机号码",@"请填写您所在俱乐部及身份"],@[@"不同资源之间请用＃分割",@"不同资源之间请用＃分割"],@[@"请输入详细地址",@"用于接收资料"]];
    //self.tips = @[@[@"使用真实姓名方便好友找到你，也能显示出对别人的尊重。",@"",@""],@[@"",@""],@[@"请输入详细地址",@"用于接收邮件所用，请填写正确格式的邮箱地址"]];
    [self.view addSubview:self.tableView];
}
- (void)configHeadFooter
{
    NSLog(@"🌹configHeadFooter====%ld",self.type);
    if (self.type == EditTypeAddFriends) {
        
        self.isClickEdit = NO;//已生成名片，为不可编辑状态，显示名片
        cardView.hidden = NO;
        shareButton.hidden = YES;
        self.title = @"个人名片";
        
        erweimaView.image = [QRCodeCreateTool createQRCodeWithString:[NSString stringWithFormat:@"%@user/saoUserCard/info?mobilePhone=%@",PublicServer,self.info.cardPhone]];
        
        nameLabel.text = [NSString stringWithFormat:@"%@\n%@",self.info.name,self.info.position];
        phoneLabel.text = [NSString stringWithFormat:@"Phone：%@",self.info.cardPhone];
        emailLbael.text = [NSString stringWithFormat:@"Email: %@",self.info.emailAddress];
        addressLabel.text = [NSString stringWithFormat:@"Address: %@",self.info.detailedAddress];
        NSString *leftStr = [self.info.proIdNames stringByReplacingOccurrencesOfString:@"#" withString:@"\n"];
        leftLabel.text = leftStr;
        NSString *rightStr = [self.info.demIdNames stringByReplacingOccurrencesOfString:@"#" withString:@"\n"];
        rightLabel.text = rightStr;
        
        [cardBottomBtn setTitle:@"加入我的人脉" forState:UIControlStateNormal];
        //已经是好友隐藏加好友按钮
        if (self.info.status == 2) {
            cardBottomBtn.hidden = YES;
        }
    }
}
- (void)createCardClick
{
    NSLog(@"🌹createCardClick");
    
    if (self.info.name.length<1) {
        [MBProgressHUD showError:@"姓名不能为空" toView:self.view];
        return;
    }else if (![VefityTool isValidTellNumber:self.info.cardPhone]){
        [MBProgressHUD showError:@"请输入正确的手机号码" toView:self.view];
        return;
    }else if (self.info.position.length<1){
        [MBProgressHUD showError:@"身份不能为空" toView:self.view];
        return;
    }else if (self.info.proIdNames.length<1){
        [MBProgressHUD showError:@"提供资源不能为空" toView:self.view];
        return;
    }else if (self.info.demIdNames.length<1){
        [MBProgressHUD showError:@"需求资源不能为空" toView:self.view];
        return;
    }else if (self.info.detailedAddress.length<1){
        [MBProgressHUD showError:@"详细地址不能为空" toView:self.view];
        return;
    }else if (self.info.emailAddress.length<1){
        [MBProgressHUD showError:@"邮箱地址不能为空" toView:self.view];
        return;
    }
    NSMutableDictionary *parame = [NSMutableDictionary dictionary];
    parame[@"token"] = [SZLAccountHelper shareInstance].token;
    parame[@"name"] = self.info.name;
    parame[@"cardPhone"] = self.info.cardPhone;
    parame[@"position"] = self.info.position;
    parame[@"provideResources"] = self.info.proIdNames;
    parame[@"demandResources"] = self.info.demIdNames;
    parame[@"detailedAddress"] = self.info.detailedAddress;
    parame[@"emailAddress"] = self.info.emailAddress;
    [self showWaiter];
    NSLog(@"🌹上传的信息==%@",parame);
    [PersonNetWork editCardInfoWithParame:parame response:^(BOOL success, NSString *msg) {
        [self hideWaiter];
        
        if (success) {
            
            self.isClickEdit = NO;//已生成名片，为不可编辑状态，显示名片
            cardView.hidden = NO;
            shareButton.hidden = NO;
            self.title = @"个人名片";
            nameLabel.text = [NSString stringWithFormat:@"%@\n%@",self.info.name,self.info.position];
            phoneLabel.text = [NSString stringWithFormat:@"Phone：%@",self.info.cardPhone];
            emailLbael.text = [NSString stringWithFormat:@"Email: %@",self.info.emailAddress];
            addressLabel.text = [NSString stringWithFormat:@"Address: %@",self.info.detailedAddress];
            NSString *leftStr = [self.info.proIdNames stringByReplacingOccurrencesOfString:@"#" withString:@"\n"];
            leftLabel.text = leftStr;
            NSString *rightStr = [self.info.demIdNames stringByReplacingOccurrencesOfString:@"#" withString:@"\n"];
            rightLabel.text = rightStr;
            [MBProgressHUD showSuccess:msg toView:self.view];
            
            [self.tableView reloadData];
        }else{
            [MBProgressHUD showError:msg toView:self.view];
        }
    }];
}

#pragma mark - Table view data source
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 6;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenW,85)];
    view.backgroundColor = RGBColorA(239, 239, 239, 1);
    return view;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.titles.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.titles[section] count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    EditCardCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([EditCardCell class])];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.title = self.titles[indexPath.section][indexPath.row];
    cell.places = self.placeHolders[indexPath.section][indexPath.row];
    cell.model = self.info;
    cell.contentField.delegate = self;
    cell.contentField.tag = indexPath.section * 10 + indexPath.row;
    return cell;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [UIView animateWithDuration:0.28 animations:^{
        self.cityPicker.transform = CGAffineTransformIdentity;
    }];
}
#pragma mark---------------------------------------------
- (void)getCardInfo
{
    NSMutableDictionary *parame = [NSMutableDictionary dictionary];
    parame[@"token"] = [SZLAccountHelper shareInstance].token;
    [self showClearBgWaiter];
    [PersonNetWork cardInfoWithParame:parame response:^(BOOL success, NSString *msg,CardInfoModel *info) {
        
        [self hideWaiter];
        if (success) {
            self.info = info;
            NSLog(@"self.info.share = %@",self.info.shareUrl);
            if (self.info.name.length<1) {
                self.isClickEdit = YES;//还未生成名片，为编辑状态，显示输入框
                cardView.hidden = YES;
                shareButton.hidden = YES;
                self.title = @"编辑名片";
                
            }else{
                self.isClickEdit = NO;//已生成名片，为不可编辑状态，显示名片
                cardView.hidden = NO;
                shareButton.hidden = NO;
                self.title = @"个人名片";
                
                nameLabel.text = [NSString stringWithFormat:@"%@\n%@",info.name,info.position];
                phoneLabel.text = [NSString stringWithFormat:@"Phone：%@",self.info.cardPhone];
                emailLbael.text = [NSString stringWithFormat:@"Email: %@",self.info.emailAddress];
                addressLabel.text = [NSString stringWithFormat:@"Address: %@",self.info.detailedAddress];
                NSString *leftStr = [self.info.proIdNames stringByReplacingOccurrencesOfString:@"#" withString:@"\n"];
                leftLabel.text = leftStr;
                NSString *rightStr = [self.info.demIdNames stringByReplacingOccurrencesOfString:@"#" withString:@"\n"];
                rightLabel.text = rightStr;
                NSLog(@"+++++++++++++++%@",self.info.proIdNames);
            }
            [self configHeadFooter];
            [self.tableView reloadData];
            [self hideRequestAgainView];
        }else{
            if ([msg isEqualToString:NoNetworkStatus]) {
                [self showRequestAgainView:@selector(getCardInfo)];
            }
            [MBProgressHUD showError:msg toView:self.view];
        }
    }];
}
- (void)addFriends
{
    NSMutableDictionary *parame = [NSMutableDictionary dictionary];
    parame[@"token"] = [SZLAccountHelper shareInstance].token;
    parame[@"friendMobilePhone"] = self.friendsPhone;
    [self showClearBgWaiter];
    [PersonNetWork addCardFriendsInfoWithParame:parame response:^(BOOL success, NSString *msg) {
        [self hideWaiter];
        if (success) {
            [cardBottomBtn setTitle:@"发消息" forState:(UIControlStateNormal)];
            [MBProgressHUD showSuccess:@"成功添加好友" toView:self.view];
            self.type = EditTypeChatWithSeller;
            [self cardBottomBtnClick];

        }else{
            [MBProgressHUD showError:msg toView:self.view];
        }
    }];
}
//获取个人信息
- (void)getPersonInfo
{
    NSMutableDictionary *parame = [NSMutableDictionary dictionary];
    parame[@"token"] = [SZLAccountHelper shareInstance].token;
    [PersonNetWork getPersonInfoWithParame:parame response:^(BOOL success, NSString *msg,NSString *errorCode,PersonInfo *info) {
        
        if (success) {
            self.personInfo = info;
        }else{
            [MBProgressHUD showError:msg toView:self.view];
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                if ([errorCode isEqualToString:NoLoginStatus]) {
                    [self.navigationController popToRootViewControllerAnimated:YES];
                    SZLTabBarViewController *barVc = (SZLTabBarViewController*)[UIApplication sharedApplication].keyWindow.rootViewController;
                    barVc.selectedIndex = 0;
                    [SZLAccountHelper clearAlreadyInfo];
                    [SZLAccountHelper shouldLogin];
                }
            });
        }
    }];
}
- (void)getOtherCardInfo
{
    NSMutableDictionary *parame = [NSMutableDictionary dictionary];
    parame[@"token"] = [SZLAccountHelper shareInstance].token;
    parame[@"id"] = @(self.ID);
    [self showClearBgWaiter];
    __WEAK
    [PersonNetWork getOtherCardInfoWithParame:parame response:^(BOOL success, NSString *msg,CardInfoModel *info) {
        [self hideWaiter];
        if (success) {
            self.info = info;
            if (info.name.length < 1) {
                [MBProgressHUD showError:@"该好友尚未编辑名片" toView:self.view];
                [weakSelf.navigationController popViewControllerAnimated:YES];
                
                //                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                //                });
            }else {
                if (self.type == EditTypeChatWithSeller) {
                    [cardBottomBtn setTitle:@"联系商家" forState:UIControlStateNormal];
                    self.friendsPhone = self.info.mobilePhone;
                    [self addFriends];
                }else {
                    //已经是好友隐藏加好友按钮
                    if (info.status == 1) {
                        cardBottomBtn.hidden = YES;
                    }
                }
            self.isClickEdit = NO;//已生成名片，为不可编辑状态，显示名片
            cardView.hidden = NO;
            shareButton.hidden = YES;
            cardBottomBtn.hidden = YES;
            self.title = @"个人名片";
            
            erweimaView.image = [QRCodeCreateTool createQRCodeWithString:[NSString stringWithFormat:@"%@user/saoUserCard/info/send?mobilePhone=%@",PublicServer,self.info.cardPhone]];
            
            nameLabel.text = [NSString stringWithFormat:@"%@\n%@",info.name,info.position];
            phoneLabel.text = [NSString stringWithFormat:@"Phone：%@",self.info.cardPhone];
            emailLbael.text = [NSString stringWithFormat:@"Email: %@",self.info.emailAddress];
            addressLabel.text = [NSString stringWithFormat:@"Address: %@",self.info.detailedAddress];
            NSString *leftStr = [self.info.proIdNames stringByReplacingOccurrencesOfString:@"#" withString:@"\n"];
            leftLabel.text = leftStr;
            NSString *rightStr = [self.info.demIdNames stringByReplacingOccurrencesOfString:@"#" withString:@"\n"];
            rightLabel.text = rightStr;
            
            [weakSelf.tableView reloadData];
            
            }
        }else{
            [MBProgressHUD showError:msg toView:self.view];
        }
    }];
}

- (QRCodeCell *)headView
{
    if (!_headView) {
        _headView = [[[NSBundle mainBundle]loadNibNamed:NSStringFromClass([QRCodeCell class]) owner:nil options:nil]lastObject];
        if ([SZLAccountHelper isAlreadyLogin]) {
            _headView.image = [QRCodeCreateTool createQRCodeWithString:[NSString stringWithFormat:@"%@user/saoUserCard/info?mobilePhone=%@",PublicServer,[SZLAccountHelper shareInstance].mobilePhone]];
        }
    }
    return _headView;
}
- (UIButton *)footBtn
{
    if (!_footBtn) {
        _footBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 45, ScreenW, 40)];
        _footBtn.backgroundColor = RGBColorA(50, 134, 189, 1);
        _footBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [_footBtn setTitle:@"生成名片" forState:(UIControlStateNormal)];
        [_footBtn addTarget:self action:@selector(createCardClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _footBtn;
}
- (ProvincesPicker *)cityPicker
{
    if (!_cityPicker) {
        _cityPicker = [ProvincesPicker picker];
        _cityPicker.frame = CGRectMake(0, ScreenH, ScreenW, 216);
        __WEAK
        _cityPicker.selectModel = ^(NSString *name){
            weakSelf.info.detailedAddress = name;
            [UIView animateWithDuration:0.28 animations:^{
                weakSelf.cityPicker.transform = CGAffineTransformIdentity;
            }];
            [weakSelf.tableView reloadData];
        };
    }
    return _cityPicker;
}
- (UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenW,ScreenH-64) style:UITableViewStyleGrouped];
        _tableView.dataSource = self;
        _tableView.delegate = self;
        _tableView.sectionFooterHeight = 0.01;
        _tableView.backgroundColor = [UIColor whiteColor];
        
        _tableView.rowHeight = UITableViewAutomaticDimension;
        _tableView.estimatedRowHeight = 60;
        [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([EditCardCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([EditCardCell class])];
    }
    return _tableView;
}

@end
